package com.cloud.configure;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Swagger2 文档配置
 *
 * @author yzj
 */
@Configuration
public class SwaggerConfiguration {

    // 文档名称
    @Value("${knife4j.title}")
    private String title;
    // 文档说明
    @Value("${knife4j.description}")
    private String description;
    // 文档版本
    @Value("${knife4j.version}")
    private String version;

    @Bean
    public GroupedOpenApi adminApi() {
        return GroupedOpenApi.builder().group("default").pathsToMatch("/**").build();
    }

    @Bean
    public OpenAPI openAPI() {
        // 增加swagger授权请求头配置
        return new OpenAPI().info(new Info().title(title).description(description).version(version));
    }

}
